<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  .box1 {
    float: left;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background-color: #fff;
  }

  .box2 {
    float: left;
    margin-top: 30px;
    width: 100px;
    height: 800px;
    background-color: #fff;
    border-radius: 200px / 400px;
  }

  .box3 {
    float: left;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background-color: pink;
  }
</style>

<body>
  <div class="box1"></div>
  <div class="box2"></div>
  <div class="box3"></div>
  <script>
    let arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
    let d = Math.floor(Math.random() * arr.length)
    let e = Math.floor(Math.random() * arr.length)
    let f = Math.floor(Math.random() * arr.length)
    let g = Math.floor(Math.random() * arr.length)
    let h = Math.floor(Math.random() * arr.length)
    let i = Math.floor(Math.random() * arr.length)
    let a = Math.floor(Math.random() * 255) + 1
    let b = Math.floor(Math.random() * 255) + 1
    let c = Math.floor(Math.random() * 255) + 1
    function getRandomColor(flag) {
      if (flag === true) {
        return `#${arr[d]}${arr[e]}${arr[f]}${arr[g]}${arr[h]}${arr[i]}`
      }
      if (flag === false) {
        return `rgba(${a},${b},${c})`
      }
    }
    console.log(getRandomColor(true));
    console.log(getRandomColor(false));
    const box1 = document.querySelector('.box1')
    const box2 = document.querySelector('.box2')
    const box3 = document.querySelector('.box3')
    box1.style.backgroundColor = getRandomColor(true);
    box2.style.backgroundColor = getRandomColor(false);
    box3.style.backgroundColor = getRandomColor(true);
  </script>
</body>

</html>